var id = getvl("id");
   $(function(){
   	   if(id!=''){
   	   	dingdandaifukuan(id);
   	   }else{
   	   	alert(".....失败");
   	   }
   });


function dingdandaifukuan(id){
	$.ajax({
		url: urlcore + "/api/order/selectOne2?id="+id,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				var da=data.data;
				  var zhuantai="";
		        if(da.status==0){
							zhuantai="未付款";
						}else if(da.status==1){
							zhuantai="支付成功";
						}else if(da.status==2){
							zhuantai="确认收货";
						}else if(da.status==3){
							zhuantai="已评价";
						}else if(da.status==4){
							zhuantai="客户删除";
						}else if(da.status==5){
							zhuantai="商家删除";
						}else if(da.status==6){
							zhuantai="都删除";
						}else if(da.status==7){
							zhuantai="订单取消";
						}else if(da.status==8){
							zhuantai="退款申请中";
						}else if(da.status==9){
							zhuantai="退款失败";
						}else if(da.status==10){
							zhuantai="退款成功";
						}
     var dingdanzhuang='<h5><span>订单状态</span><em>'+zhuantai+'</em></h5>'+
'	<ul>'+
'		<li>'+
'			<span>订单编号</span>'+
'			<em id="biao1">'+da.orderNumber+'</em>'+
'			<i class="copy">复制订单号</i>'+
'		</li>'+
'		<li>'+
'			<span>下单时间</span>'+
'			<em>'+da.gmtDatetime+'</em>'+
'		</li>'+
'		<li>'+
'			<span>买家留言</span>';
   if(da.remark==null || da.remark==""){
   	dingdanzhuang+='<em></em>';
   }
    dingdanzhuang+='</li>'+
        '</ul>';

       var fahuoxinxi='<div class="sell_detail_dz">'+
        '<span>'+da.address.userName+'</span>'+
'		<em>'+da.address.userPhone+'</em>'+
'		<i class="fuzhidz">复制地址</i>'+
'	</div>'+
'	<p id="dizhixinxi">'+da.address.province+'·'+da.address.city+'·'+da.address.county+'.'+da.address.address+'</p>';
     
     
     var maijiaxinxi='<h6>买家:'+da.user.userName+'</h6>'+
'	<div class="fr">'+
'		<a href="sms:'+da.user.phone+'">'+
'			<img src="../images/sell_chat.png" />'+
'		</a>'+
'		<a href="tel:'+da.user.phone+'">'+
'			<img src="../images/sell_tel.png" />'+
'		</a>'+
'	</div>';


 var shangpingxinxi="";
 var danjia="";
       $.each(da.goodsCarList, function(y,q) {
			 shangpingxinxi+='<div class="clearfix tuwen">'+
'    	<a href="../7.0.0goods_detail.html?id='+q.goods.id+'">'+
'	        <div class="tuwen-img fl">'+
'	            <img onerror="errorImg(this)" src="'+q.goods.coverUrl+'" width="75" height="75">'+
'	        </div>'+
'	        <div class="tuwen-wenzi">'+
'	            <h5 class="wuye_h01">'+q.goods.goodsTitle+'</h5>'+
'	            <div class="wuye_div01">产品质量均有保障</div>'+
'	        </div>'+
'        </a>'+
'    </div>';
		 $.each(q.myStockList,function(y,n){
			shangpingxinxi += ' <div class="dingdan_fenlei clearfix">' +
 								'    	<ul class="fl">' +
 								'    		<li>颜色：<span>'+n.colour.colourName+'</span></li>'+
'    		<li>尺码：<span>'+n.size.sizeName+'</span></li>'+
'    		<li>单价：<span>'+q.packRate+'元/件</span></li>'+'    	</ul>' +
 								'    	<div class="fr">' +
 								'    		<h5>' + ((q.packRate*n.saleNum).toFixed(2))+ '元</h5>' +
 								'    		<h6>' + n.saleNum + '件</h6>' +
 								'    	</div>' +
 								'    </div>';
			 });
			 });
          var shangpingxinxiss='<div class="sell_detail">'+
'    	<h5>共<em>'+da.goodsNumber+'</em>件<span>(含运费'+da.freightMoney+'元)</span></h5>'+
'    	<h6>实收费：<span>&yen;'+da.payMoney+'</span></h6>'+
'    </div>';
         $("#dingdanzhuang").append(dingdanzhuang);
            $("#fahuoxinxi").append(fahuoxinxi);
               $("#shangpingxinxi").append(shangpingxinxi);
               $("#maijiaxinxi").append(maijiaxinxi);
               
                $("#shangpingxinxiss").append(shangpingxinxiss);
            $("#anniu").html("");
     	var anniu='<a href="javascript:void(0);" onclick="goupdate(this)"   id="'+da.orderNumber+'" class="sell_dingdan_huang P-xiugai">修改价格</a>'+
'<input type="hidden" value="'+da.freightMoney+'" id="mails">'+
'<input type="hidden" value="'+da.payMoney+'" id="Ordertotalprice">';
			$("#anniu").html(anniu);
			
			
			$(function(){
				    // 取消订单
    // 弹出
    $(".P-xiugai").on('click',function(){
        $("body").append("<div id='mask'></div>");
        $(".sell-xiugai1").show();
    })
    //点击关闭
    $(".show2_anniu span").on('click',function(){
        $(".sell-xiugai1").hide();
        $("#mask").remove();
    }) 
    
    
    	 var copyBtn = document.querySelector('.copy')

  // 点击的时候调用 copyTextToClipboard() 方法就好了.
  copyBtn.onclick = function() {
  	var leirongs=$("#biao1").html();
    copyTextToClipboard(leirongs);
  }
           	 var copyBtndz = document.querySelector('.fuzhidz')
  // 点击的时候调用 copyTextToClipboard() 方法就好了.
  copyBtndz.onclick = function() {
  	var leirongs=$("#dizhixinxi").html();
    copyTextToClipboard(leirongs);
  }


  function copyTextToClipboard(text) {
   var textArea = document.createElement("textarea")
    textArea.style.position = 'fixed'
    textArea.style.top = 0
    textArea.style.left = 0
    textArea.style.width = '2em'
    textArea.style.height = '2em'
    textArea.style.padding = 0
    textArea.style.border = 'none'
    textArea.style.outline = 'none'
    textArea.style.boxShadow = 'none'
    textArea.style.background = 'transparent'
    textArea.value = text
    document.body.appendChild(textArea)
    textArea.select()
    try {
      var msg = document.execCommand('copy') ? '成功' : '失败'
      console.log('复制内容 ' + msg)
    } catch (err) {
      console.log('不能使用这种方法复制内容')
    }
  document.body.removeChild(textArea)
       }
			})
			}
		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	

	
}


function goupdate(te){
	   $("#ordernaber").val("");
  var tuifeioderid=$(te).attr("id");
   $("#ordernaber").val(tuifeioderid);
   var yuns=$(te).next().val();
   var Ordertotalprice=$(te).next().next().val();
   var zongjia=parseFloat(yuns)+parseFloat(Ordertotalprice);
   $("#shishoujineorid").html(zongjia);
   $("#yunfeioid").val(yuns);
   $("#huokaunorid").val(Ordertotalprice);
}



function xiugaimaliy(){  //修改价格
   var	huokaunorid=parseFloat($("#huokaunorid").val());
  var yunfeioid=parseFloat($("#yunfeioid").val());
   var ordernaber=$("#ordernaber").val();
	if(ordernaber!="" && uuuuid!="" ){
   	  $.ajax({
      url: urlcore+"/api/order/updatePrice2?orderNumber="+ordernaber+"&userid="+uuuuid+"&payMoney="+huokaunorid+"&freightMoney="+yunfeioid,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
			/*	var lujing=window.location.href;
				window.location.href=lujing;*/
				window.location.reload(); 
					
				}
		/*console.log(goodslist);*/
			},
			error: function() {
				alert("error");
			}
		});
		
	}
}